package com.zxy.supplier_system.server.entity

import jakarta.persistence.*
import org.hibernate.annotations.ColumnDefault
import java.io.Serializable

@Entity
@IdClass(MarketGoods.UnionId::class)
class MarketGoods {

    data class UnionId(
        var market:Int? = null,
        var goods:Int? = null
    ): Serializable

    @Id
    @ManyToOne(optional = false)
    @JoinColumn
    lateinit var goods: Goods

    @Id
    @ManyToOne(optional = false)
    @JoinColumn
    lateinit var market: Market

    @Column(nullable = false)
    @ColumnDefault("0")
    var amount:Int = 0

}